package com.leagueoflegends.service.impl;

import com.github.pagehelper.PageHelper;
import com.leagueoflegends.bean.Champion;
import com.leagueoflegends.mapper.ChampionMapper;
import com.leagueoflegends.service.ChampionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ChampionServiceImpl implements ChampionService {

    @Autowired
    ChampionMapper championMapper;

    @Override
    public void insert(Champion champion) {
        championMapper.insert(champion);
    }

    @Override
    public void delete(Integer id) {
        championMapper.delete(id);
    }

    @Override
    public void update(Champion champion) {
        championMapper.update(champion);
    }

    @Override
    public void regainChampion(int id) {
        championMapper.regainChampion(id);
    }

    @Override
    public Champion selectById(Integer id) {
        return championMapper.selectById(id);
    }

    @Override
    public List<Champion> selectAll(int pageNum, int pageSize, String type, String find) {
        PageHelper.startPage(pageNum, pageSize);
        return championMapper.selectAll(type, find);
    }

    // 以下三个为前台实现
    @Override
    public List<Champion> getAllChampion() {
        return championMapper.getAllChampion();
    }

    @Override
    public List<Champion> getChampionByTitle(String title) {
        return championMapper.getChampionByTitle(title);
    }


    @Override
    public List<Champion> selectByJob(String job) {
        return championMapper.selectByJob(job);
    }
}
